home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9136 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: ix.netcom.com!news
  2. From: Norman Bullen <nbullen@ix.netcom.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Standard question - pointer initialization
  5. Date: Wed, 06 Mar 1996 20:03:52 -0800
  6. Organization: Black Cat Associates
  7. Message-ID: <313E6028.1C19@ix.netcom.com>
  8. References: <4hk9un$906@hammer.msfc.nasa.gov> <4hl6rr$nde@news.xs4all.nl>
  9. NNTP-Posting-Host: ple-ca9-19.ix.netcom.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-NETCOM-Date: Wed Mar 06 10:01:08 PM CST 1996
  14. X-Mailer: Mozilla 2.0 (Win16; I)
  15.  
  16. Falstaff wrote:
  17. > Brian.Day@msfc.nasa.gov (Brian Day) writes:
  18. > >Hi all,
  19. > >I don't have a copy of the ANSI standard handy, and was wondering
  20. > >if y'all could answer a question for me.
  21. > >We were recently handed a coding standard which said:
  22. > >    "Always initialize pointers when they are declared"
  23. > >Doesn't the standard say something about some pointers
  24. > >being automatically initialized to NULL, or something like that?
  25. > No.  Pointers like any other variables are not automagically initialized.
  26. > >Is this coding standard wise?
  27. > Even though using uninitialized pointers may lead to crashing your
  28. > system (especially non-memory-managed systems) faster than other
  29. > uninitialized variables, both omissions will lead to errors in the
  30. > program.
  31. > Compilers may help in detecting uninitialized variables, but otherwise
  32. > good programming practises should be followed to try to eliminate
  33. > these errors before they are programmed in.
  34. > Frank
  35. > --
  36. > The famous GIICM now on line:  http://www.xs4all.nl/~falstaff/GIICM.html
  37. > ------------------------------------------------------------------------> Frank A. Vorstenbosch        +31-(70)-355 5241        falstaff@xs4all.nl
  38.  
  39. And there is no point in initializing a pointer when its declared if you 
  40. don't know at that point what an appropriate value might be. Use of a 
  41. pointer that has been initialized with an inappropriate value can be just 
  42. as bad for the program as using an uninitialize pointer.
  43.